import { makeAutoObservable } from 'mobx'
import { createTrainings, teachertLogin } from './api'
import { setCookie, setSessionStorage } from '@/storage'

class Store {
    /** 用户登录信息 */
    userInfo: any = {}

    constructor() {
        makeAutoObservable(this)
    }

    /** 教师端快捷登录 */
    teacherquickLogin = (data: any) => {
        return teachertLogin(data).then(res => {
            console.log(res)
            this.userInfo = res.data
            setCookie('TOKEN', res.data.access_token)
            setSessionStorage('TEACHER_USER_INFO', res.data)
        })
    }

    /** 创建AI面试 */
    createTrainings = (data: any) => {
        return createTrainings(data)
    }
}

const store = new Store()
export default store
